/**
 * @Author:Geln Yang
 * @Created:2008-8-3
 * $ Revision: 1.0 $
 * $ Author: Geln Yang $
 * $ Date: 2008-8-3 $
 */
package org.geln.web.webwork.interceptor;

import org.geln.web.webwork.action.Layout;

import com.opensymphony.xwork.Action;
import com.opensymphony.xwork.ActionInvocation;
import com.opensymphony.xwork.interceptor.Interceptor;

/**
 * @Author:Geln Yang
 * @Created:2008-8-3
 */
public class PageSizeInterceptor implements Interceptor {

	private static final int DEFAULTPAGESIZE = 10;

	private int defaultPageSize = DEFAULTPAGESIZE;

	public void destroy() {
	}

	public void init() {
	}

	public String intercept(ActionInvocation invocation) throws Exception {
		Action action = (Action) invocation.getAction();
		if (action instanceof Layout) {
			Layout customLayoutAction = (Layout) action;
			customLayoutAction.getPage().setPageSize(defaultPageSize);
		}
		return invocation.invoke();
	}

}
